<template>
  <div :class="[`nav-theme-${navTheme}`, `nav-layout-${navLayout}`]">
    <a-layout
      id="components-layout-demo-custom-trigger"
      style="min-height: 100vh"
    >
      <a-layout-sider
        v-show="navLayout === 'left'"
        :theme="navTheme"
        v-model="collapsed"
        :trigger="null"
        collapsible
      >
        <div class="logo">Ant Design Vue Pro</div>
        <SiderMenu
          :navTheme="navTheme"
          @handleBreadcrumb="handleBreadcrumb"
          :navLayout="navLayout"
        ></SiderMenu>
      </a-layout-sider>
      <a-layout>
        <a-layout-header style="background: #fff; padding: 0">
          <a-icon
            v-show="navLayout === 'left'"
            class="trigger"
            :type="collapsed ? 'menu-unfold' : 'menu-fold'"
            @click="() => (collapsed = !collapsed)"
          />
          <my-header :navTheme="navTheme" :navLayout="navLayout" />
        </a-layout-header>
        <a-layout-content style="margin: 0 16px">
          <a-breadcrumb style="margin: 16px 0">
            <a-breadcrumb-item
              :key="index"
              v-for="(breadcrumbItem, index) in breadcrumbData"
              >{{ breadcrumbItem }}</a-breadcrumb-item
            >
          </a-breadcrumb>
          <div :style="{ padding: '24px', background: '#fff' }">
            <router-view></router-view>
          </div>
        </a-layout-content>
        <a-layout-footer style="text-align: center">
          <my-footer></my-footer>
        </a-layout-footer>
      </a-layout>
      <setting-drawer></setting-drawer>
    </a-layout>
  </div>
</template>
<script>
import MyFooter from "./MyFooter.vue";
import MyHeader from "./MyHeader.vue";
import SettingDrawer from "./SettingDrawer.vue";
import SiderMenu from "./SiderMenu.vue";
export default {
  components: { SiderMenu, SettingDrawer, MyHeader, MyFooter },
  data() {
    return {
      collapsed: false,
      breadcrumbData: [],
    };
  },
  computed: {
    navTheme() {
      return this.$route.query.navTheme || "dark";
    },
    navLayout() {
      return this.$route.query.navLayout || "left";
    },
  },
  methods: {
    handleBreadcrumb(value) {
      this.breadcrumbData = value;
    },
  },
};
</script>
<style scoped>
#components-layout-demo-custom-trigger .trigger {
  font-size: 18px;
  line-height: 64px;
  padding: 0 24px;
  cursor: pointer;
  transition: color 0.3s;
}

#components-layout-demo-custom-trigger .trigger:hover {
  color: #1890ff;
}
#components-layout-demo-custom-trigger .logo {
  margin: 16px;
  text-align: center;
  height: 64px;
  line-height: 64px;
  overflow: hidden;
}

.nav-theme-dark #components-layout-demo-custom-trigger .logo {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}
.nav-theme-light #components-layout-demo-custom-trigger .logo {
  color: black;
  background: rgba(255, 255, 255, 1);
}
</style>
